Skip to content

ci: publish PR previews as real GitHub deployments - #5371

Open
cixzhang wants to merge 2 commits into
mainfrom
feat/ci-deployment-records
Open

ci: publish PR previews as real GitHub deployments#5371
cixzhang wants to merge 2 commits into
mainfrom
feat/ci-deployment-records

Conversation

@cixzhang

@cixzhang cixzhang commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

Storybook and Sandbox previews are published to GitHub Pages, but GitHub only sees the bot comment that links them. Reviewers using the PR timeline or the Deployments API cannot discover either preview as a deployment.

What changes

  • The shared gh-pages publisher creates transient Storybook and Sandbox deployments on the trusted PR head, but only for targets its publication result confirms are live.
  • A failed attempted publish records failure; an expired-artifact manual re-deploy stops before the publisher, so it records nothing.
  • Cleanup retires every historical deployment whose stable Preview for PR #<n> description matches a stale preview before deleting the directory. If retirement fails, the directory remains so the next cleanup retries safely.
  • The three workflows add only deployments: write; publishing, recording, and cleanup remain centralized in the existing publisher.

Load-bearing API details

  • required_contexts: [] prevents deployment creation from returning 409 conflict while unrelated PR checks are still running.
  • auto_inactive: false prevents one PR's success from retiring every other live PR that shares the Storybook or Sandbox environment name.
  • transient_environment: true identifies these as previews that cleanup will deactivate.

Test plan

  • pnpm vitest run .github/scripts/lib/gh-pages-publisher.test.mjs .github/scripts/visual-gate/workflow-concurrency.test.mjs --project node --maxWorkers=1 — 61 passed
  • pnpm check:repo — passed
  • actionlint -ignore SC2129 on the three changed workflows — passed
  • pnpm exec prettier --check on all six changed files — passed
  • git diff --check and the public-repo residue guard — passed

@vercel

vercel Bot commented Aug 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
astryx Ready Ready Preview Sep 3, 2026 5:14pm UTC

Request Review

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Meta Open Source bot. label Aug 23, 2026
@github-actions

github-actions Bot commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

PR Analysis Report

📚 Storybook Preview

View Storybook for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

🧪 Sandbox Preview

View Sandbox for this PR
GitHub Pages may take up to a minute to hydrate after deploy.

No new or modified components detected.

Bundle Size Summary

No component packages changed.

Accessibility Audit

Status: No accessibility violations detected.


Generated by PR Enrichment workflow | Storybook | Sandbox | View full report

github-actions Bot added a commit that referenced this pull request Aug 24, 2026
@cixzhang

Copy link
Copy Markdown
Contributor Author

Direction: keep the deployment integration. Storybook and Sandbox previews should be first-class GitHub Deployments with cleanup, not links discoverable only by parsing bot comments.

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — the required_contexts and auto_inactive notes each save someone a day, and the probe table is the right evidence.

Two things before it lands.

Records are written per commit and retired per PR head. Over the last 20 closed PRs that is 150 records against 40 retirements: 110 success records keep a live link to a pr/<n>/ directory the same job just deleted.

And the manual re-deploy's always() has no equivalent of deploy-preview's verify.ready guard — the two inline copies have already drifted — so with #5519 on main its "artifacts expired, re-run CI" stop posts failure for both environments while the preview is still live.

For the retirement, does matching the description you already write feel right, or would you rather walk the PR's commits?

[Reviewed by Robohands]

Comment thread .github/workflows/cleanup-previews.yml Outdated
# A PR with nothing left to retire is the normal case on a rerun,
# so an empty list must not trip `set -u`.
ids=()
mapfile -t ids < <(gh api "/repos/${GITHUB_REPOSITORY}/deployments?sha=${head_sha}&environment=${environment}" --jq '.[].id' 2>/dev/null)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only the head commit. Every earlier push's record stays active pointing at the directory just deleted.

Comment thread .github/workflows/redeploy-preview.yml Outdated
# nothing, so it cannot call a local composite action (the gh-pages push
# loop above is duplicated for the same reason).
- name: Record the preview as a GitHub deployment
if: always()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, always() fires on skipped and cancelled too. deploy-preview gates on verify.ready; this doesn't.

@cixzhang
cixzhang force-pushed the feat/ci-deployment-records branch 3 times, most recently from be646be to b204b46 Compare August 29, 2026 17:19

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — both blockers are fixed. Cleanup retires every matching historical record, and an expired manual re-deploy records nothing. The shared publisher keeps the paths together. Ready.

[Reviewed by Robohands]

github-actions Bot added a commit that referenced this pull request Aug 29, 2026
@cixzhang
cixzhang force-pushed the feat/ci-deployment-records branch 2 times, most recently from 4479068 to 7ee68a8 Compare August 31, 2026 19:09
Storybook and Sandbox previews were published to GitHub Pages but invisible
to GitHub's deployment-aware surfaces.

Teach the shared gh-pages publisher to create transient deployments for both
preview URLs, record a failed publish as failure, and retire every historical
record for a preview when cleanup removes it. Automatic and manual publishing
now use the same implementation, while the workflows only grant the required
permission and pass the trusted PR head.
@cixzhang
cixzhang force-pushed the feat/ci-deployment-records branch from 7ee68a8 to 9445b3b Compare August 31, 2026 19:10
github-actions Bot added a commit that referenced this pull request Aug 31, 2026

@cixzhang cixzhang left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — the prior cleanup and expired-artifact blockers remain fixed. The rebase keeps one publisher and records only confirmed Storybook/Sandbox targets. Ready.

[Reviewed by Robohands]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant